#include <stdint.h>
#include <arch/interrupts.h>
#include <arch/cpu.h>
#include <gic.h>


void arch_irq_enable(unsigned id)
{
    gic_set_enable(id, true); 
    gic_set_route(id, get_cpuid());
}

void arch_irq_disable(unsigned id)
{
    gic_set_enable(id, false); 
}

void arch_irq_set_prio(unsigned id, unsigned prio)
{
    gic_set_prio(id, (uint8_t) prio);
}

void arch_irq_send_ipi(uint64_t target_cpu, uint64_t ipi_id)
{
    if (ipi_id < GIC_MAX_SGIS)
        gic_send_sgi(target_cpu, ipi_id);
}

void arch_interrupts_init(void)
{
    gic_init();

    arch_local_irq_enable();
}

